﻿<phone:PhoneApplicationPage 
    x:Class="Omnia.Wallet.Views.CardAddView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:viewmodel="clr-namespace:Omnia.ViewModels;assembly=Omnia.ViewModels"
    xmlns:converters="clr-namespace:Omnia.Converters;assembly=Omnia.Converters"
    xmlns:UX="clr-namespace:Omnia.UX;assembly=Omnia.UX"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </phone:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot" >
        <Grid.DataContext>
            <viewmodel:CardsViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush ImageSource="{Binding BackgroundImageSource}" Stretch="{Binding GlobalSettings.BackgroundImageStretch}"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,12">
            <TextBlock Text="{StaticResource IDS_PAGE_TITLE}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{StaticResource IDS_PAGE_HEADER_CARD_ADD}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <ScrollViewer>
                <StackPanel>
                    <toolkit:ListPicker ItemsSource="{Binding Path=CardKinds}" SelectedItem="{Binding CardItemToAdd.Kind, Mode=TwoWay}" Header="{StaticResource IDS_LABEL_CARD_KIND}">
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <toolkit:ListPickerItem Content="{Binding Converter={StaticResource EnumTranslateConverter}}" />
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                    </toolkit:ListPicker>
                    <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{StaticResource IDS_LABEL_CARD_NUMBER}"/>
                    <TextBox Text="{Binding Path=CardItemToAdd.CardNumber, Mode=TwoWay}" InputScope="Number" />
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <StackPanel>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{StaticResource IDS_LABEL_CARD_ALIAS}"/>
                            <TextBox Text="{Binding Path=CardItemToAdd.Alias, Mode=TwoWay}" />
                        </StackPanel>
                        <StackPanel Grid.Column="1">
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{StaticResource IDS_LABEL_CARD_MASTER}"/>
                            <TextBox Text="{Binding Path=CardItemToAdd.CardMaster, Mode=TwoWay}" />
                        </StackPanel>
                    </Grid>
                    
                    <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{StaticResource IDS_LABEL_CARD_BANK}"/>
                    <TextBox Text="{Binding Path=CardItemToAdd.IssuingBank, Mode=TwoWay}" />
                    
                    <StackPanel Visibility="{Binding Path=CardItemToAdd.ShowCreditInfo, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{StaticResource IDS_LABEL_CARD_CREDITLINE}"/>
                        <TextBox Text="{Binding Path=CardItemToAdd.CreditLine, Mode=TwoWay}"  InputScope="Number"/>
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}">
                            <Run Text="{StaticResource IDS_LABEL_CARD_REPAYMENTDAY}"/>
                            <Run Text=" : "/>
                            <Run Text="{Binding Path=CardItemToAdd.MonthlyRepaymentDay}" Foreground="{StaticResource PhoneForegroundBrush}"/>
                        </TextBlock>
                        <Slider Value="{Binding Path=CardItemToAdd.MonthlyRepaymentDay, Mode=TwoWay, StringFormat=\{0:F0\}}" 
                                Maximum="28" Minimum="1"/>
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>

            <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
                <UX:UXPathButton Margin="12" Command="{Binding CardAddCommand}"
                                 IconPath="{StaticResource PATH_ICON_SUBMIT}"
                                 Padding="10"/>
                <UX:UXPathButton  Margin="12" Uri="/Views/CardsView.xaml"
                                  Padding="11"
                                  IconPath="{StaticResource PATH_ICON_PREVIOUS}"/>
            </StackPanel>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
